package com.xsr.utils.utils;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project xiaomishangcahng
 * @date 2022/8/24 14:48
 */
public class Md5Utils {
    public  static String md5(String data){

        try {
            MessageDigest md5 = MessageDigest.getInstance("md5");
            md5.update(data.getBytes("utf-8"));
            byte[] digest = md5.digest();
           return    new BigInteger(1,digest).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }
}
